<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Dangnhap extends CI_Controller 
{

	function __construct()
	{
		parent::__construct();
		$this->load->model('dangnhap_model','dangnhap');
	}
	
	function index()
	{
		$data['title'] = "Đăng nhập website - mua ban rao vat" ;
		$this->load->view('dangnhap',$data) ;
	}
	
	function action()
	{
		$user = $this->input->post('user');	
		$pass = $this->input->post('pass');	
		$remenber = $this->input->post('remenber');	
		$rs = $this->dangnhap->member_info($user);
		if(!empty($rs) && ($rs['password']==md5($pass)))
		{
			$_SESSION['ses_login'] = $rs;
			redirect('');	
		}
		else
		{
			redirect('dangnhap');	
		}
	}
	
	function login()
	{
		$user = $this->input->post('user');	
		$pass = $this->input->post('pass');	
		$remenber = $this->input->post('remenber');	
		
		$rs = $this->dangnhap->member_info($user); //trit($rs['password'].' -- ' .md5($pass)) ;
		if(!empty($rs) && ($rs['password']==md5($pass)))
		{
			$_SESSION['ses_login'] = $rs;
			$rs = $this->dangnhap->last_login($rs['member_id']) ;
			echo 1 ;
		}
		else
		{
			echo 0;
		}
	}
	
	function logout()
	{
		$_SESSION['ses_login'] = "" ;
		redirect('home');	
	}
	
}

/* End of file welcome.php */
/* Location: ./system/application/controllers/welcome.php */